package se.webbzon.oschi01.gui;

import javax.swing.JTextField;

import se.webbzon.oschi01.nbt.Tag;
import se.webbzon.oschi01.utils.Converter;


public class NBTTextFieldDialog<T> extends NBTPopupDialog<T> {
	
	protected final JTextField value;
	
	protected final Converter<String,T> conv;

	public NBTTextFieldDialog(Tag<T> nbtTag, Converter<String,T> conv) {
		super(nbtTag);
		this.conv = conv;
		value = new JTextField(nbtTag.getValue().toString());
		createDefaultLayout(value);
	}

	@Override protected T getValue() {
		return conv.convert(value.getText());
	}

	@Override protected void setValue(T t) {
		value.setText(t.toString());
	}

}
